<template>
  <view class="user">
    <!-- 上方显示用户信息的区域 -->
    <view class="userinfo">
      <!-- 信息区域 -->
      <view class="top">
        <view class="avator">
          <uni-icons type="person-filled" size="30" 
            :color="logColor"></uni-icons>
        </view>
		  <view class="uname" v-if="store.isLogin">
		          <view>{{store.userInfo.username}}</view>
		          <view>{{store.userInfo.mobile}}</view>
		        </view>
		        <view class="uname" v-else @tap="toLogin">点击登录</view>
		      </view>
		    </view>
    <!-- 下方显示的四项用户操作项 -->
    <view class="list">
      <uni-list>
        <uni-list-item v-for="item,index in manageList" 
          :title="item.name" :show-extra-icon="true"
          :extra-icon="item.icon" clickable link @tap="navto(index)"></uni-list-item>
      </uni-list>
    </view>
  </view>
</template>

<script setup>
	import {ref} from 'vue'
	import{userStore} from "@/store/userStore.js"
	// 在页面中床架状态库
	let store=userStore()
	
	const manageList = ref([{
	  name: '订单管理',
	  icon: {
	    color: '#56c48b',
	    size: '22',
	    type: 'shop'
	  }
	}, {
	  name: '地址管理',
	  icon: {
	    color: '#ff6700',
	    size: '22',
	    type: 'location-filled'
	  }
	}, {
	  name: '我的收藏',
	  icon: {
	    color: '#0225ff',
	    size: '22',
	    type: 'star'
	  }
	}, {
	  name: '设置',
	  icon: {
	    color: '#0081b9',
	    size: '22',
	    type: 'gear'
	  }
	}])
	let logColor=ref("#ccc")
	
	function toLogin(){
		uni.navigateTo({
			url:'/pages/login/login'
		})
	}
</script>

<style lang="scss">
	.user{
		height: calc( 100vh - 97px);
		border: 1px solid red;
		background-color: $uni-bg-color-grey;
		// 上方橙色区域
		.userinfo{
			height: 200px;
			background-color: #ffab7e;
			overflow:hidden;;
			
			.top{
				display: flex;
				align-items: center;
				margin: 40px 0 0 30px;
				// border:1px solid green;
				
				.avator{
					width: 40px;
					height: 40px;
					background-color: #fff;
					border-radius:50%;
					text-align:center;
					line-height: 40px;
				}
				.uname{
					color:#fff;
					margin-left:10px
				}
			}
		}
		
		.list{
			width: 700rpx;
			margin:25rpx auto;
			border-radius: 10px;
			overflow: hidden;
		}
	}

</style>
